//
//  UIBarButtonItem+Extensions.swift
//  传智微博
//
//  Created by Pro on 2017/8/3.
//  Copyright © 2017年 liuyanwei. All rights reserved.
//

import Foundation

extension UIBarButtonItem {
    
    //创建UIBarButtonItem
    
    convenience init(title:String, fontSize:CGFloat = 16, target: AnyObject?, action:Selector,isBack:Bool = false) {
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage.init(named: imageName), for:.normal)
            btn.setImage(UIImage.init(named: imageName+"_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        btn.addTarget(target, action:action, for: .touchUpInside)
        self.init(customView: btn)
//        navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: btn)
    }
}
